package com.jnr.huatu.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;

/**
 * 测量屏幕自定义view
 * @author：景辉
 * created at 2017/2/15 0015 下午 12:23
 */

public class MyView2 extends Button {
    public MyView2(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public MyView2(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyView2(Context context) {
        super(context);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int modeWidth = MeasureSpec.getMode(widthMeasureSpec);//获取宽的模式
        int modeHeight = MeasureSpec.getMode(heightMeasureSpec);//获取高的模式
        int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);//获取宽的尺寸
        int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);//获取高的尺寸
        Log.i("TAG", "modeWidth(获取宽的模式):"+modeWidth);
        Log.i("TAG", "modeHeight(获取高的模式): "+modeHeight);
        Log.i("TAG", "sizeWidth(获取宽的尺寸): "+sizeWidth);
        Log.i("TAG", "sizeHeight(获取高的尺寸): "+sizeHeight);
    }
}
